{extend name="public:base" /}

{block name="main-content"}

<div class="page-content">

    <div class="row">
        <div id="roleFormDiv" class="col-xs-12">
            <form class="roleForm" action="{:url('admin/member/set')}" method="post">
                <div class="form-group">
                    <label for="name">用户名</label>
                    <input type="text" class="form-control" id="name" name="name" value="{$member.name}" required placeholder="用户名">
                </div>
                <div class="form-group">
                    <label for="email">邮箱</label>
                    <input type="text" class="form-control" id="email" name="email" value="{$member.email}" required placeholder="邮箱">
                </div>
                <div class="form-group">
                    <label for="status">状态</label>
                    <select class="form-control" id="status" name="status">
                        {foreach  name="status" id="vo" key="key"}
                        <option value="{$key}" {if condition="isset($member) && $member->getData('status') == $key"}selected{/if}>{$vo}</option>
                        {/foreach}
                    </select>
                </div>
                <input type="hidden" id="id" name="id" value="{$member.id}">
                <button type="submit" class="btn btn-primary">保存</button>
            </form>
        </div>
    </div><!-- /.row -->
</div><!-- /.page-content -->

{/block}
{block name="scripts"}
<script type="text/javascript">
    /* 编辑角色 */
    $(function () {

        $('.roleForm').ajaxForm({
            success: roleForm, // 这是提交后的方法
            dataType: 'json'
        });
    });

    //编辑角色
    function roleForm(data) {
        if (data.code == 1) {
            $(':input','.roleForm')
            .not(':button, :submit, :reset, :hidden')
            .val('')
            .removeAttr('checked')
            .removeAttr('selected');
            layer.msg(data.msg, {icon: 6});
            if (data.url) {
                window.location.href = data.url;
            }
        } else {
            layer.msg(data.msg, {icon: 5});
        }
    }

</script>
{/block}